package com.hns.can.service.service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.hns.can.common.aop.orgTree.LeftOrgAnnotation;
import com.hns.can.common.constants.GlobalConst;
import com.hns.can.common.formula.FillCodeDscValue;
import com.hns.can.common.formula.FillParamsVo;
import com.hns.can.common.vo.CommonParamsVo;
import com.hns.can.service.entity.CommLineDeviationAlmEntity;
import com.hns.can.service.vo.LineCheapVo;
import com.hns.can.service.vo.LineOffsetStatisticsVo;
import com.hns.frame.mybatis.Pagination;
import com.hns.frame.service.CommonService;
/**
 * 线路偏移service
 * @author:zhangyu
 * @email:zhangyu2222z@sina.cn
 * @version Revision 2.0.0
 */
@Service
public class LineShiftInfoService extends CommonService {

	/**
     * 填充代码描述
     */
    @Autowired
    private FillCodeDscValue codeDscValue;
	
	@SuppressWarnings({ "unchecked", "rawtypes" })
	@LeftOrgAnnotation()
    @Transactional
	public Pagination getLineShiftStatisList(CommonParamsVo params) throws Exception{
		Pagination page = this.myBatisPage("lineDeviation.getLineDeviationCntCount", "lineDeviation.getLineDeviationCntList", params, LineCheapVo.class);
        List list = page.getData();
        Map<String,String> map = new HashMap<String,String>();
        map.put("drvName", GlobalConst.DEFAULT_CACHE_VALUE);
        FillParamsVo drv = new FillParamsVo("drvId", map);
        map = new HashMap<String,String>();
        map.put("lineName", GlobalConst.DEFAULT_CACHE_VALUE);
        FillParamsVo line = new FillParamsVo("lineId", map);
        codeDscValue.fillInfoValue(list, new String[]{
        		GlobalConst.CACHE_KEY_BASE_DRV_INFO, 
        		GlobalConst.CACHE_KEY_BASE_LINE_INFO}, 
        		drv, line);
        page.setData(list);
        return page;
	}
	
	
	/**
     * 获取线路偏移明细
     * @param params
     * @param request
     * @return
     * @throws QueryExprException
     * @author:Fisher
     * @email:zhuangcaijin@126.com
     */
	@SuppressWarnings("static-access")
    @LeftOrgAnnotation()
    @Transactional
    public Pagination getPageLineDeviation(CommonParamsVo params) throws Exception {
        Pagination page = this.myBatisPage("lineDeviation.getLineDeviationCount", "lineDeviation.getLineDeviationList", params, LineOffsetStatisticsVo.class);
        List list = page.getData();
        Map<String,String> map = new HashMap<String,String>();
        map.put("drvName", GlobalConst.DEFAULT_CACHE_VALUE);
        FillParamsVo drv = new FillParamsVo("drvId", map);
        map = new HashMap<String,String>();
        map.put("lineName", GlobalConst.DEFAULT_CACHE_VALUE);
        FillParamsVo line = new FillParamsVo("lineId", map);
        codeDscValue.fillInfoValue(list, new String[]{
        		GlobalConst.CACHE_KEY_BASE_DRV_INFO, 
        		GlobalConst.CACHE_KEY_BASE_LINE_INFO}, 
        		drv, line);
        page.setData(list);
        return page;
    }

}
